//
//  FCCompanyInfoTableViewCell.m
//  customerRelation_Example
//
//  Created by 陈文斌 on 2019/2/20.
//  Copyright © 2019 64912907. All rights reserved.
//

#import "FCRelationBindCompanyInfoTableViewCell.h"
#import "CustomerRelationHeader.h"

@interface FCRelationBindCompanyInfoTableViewCell ()
@property (nonatomic, strong) UIView *view;

@end

@implementation FCRelationBindCompanyInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        WJCWeakSelf
        self.backgroundColor = UIColor.clearColor;
        _view = [UIView new];
        [self addSubview:_view];
        [_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(16);
            make.right.mas_equalTo(-16);
            make.top.and.bottom.mas_equalTo(0);
        }];
        _view.backgroundColor = UIColor.whiteColor;
        
        _avatarImageView = [UIImageView new];
        [_view addSubview:_avatarImageView];
        [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.mas_equalTo(16);
            make.height.mas_equalTo(48);
            make.width.mas_equalTo(48);
        }];
        
        _logoImageLabel = [UILabel new];
        [_avatarImageView addSubview:_logoImageLabel];
        [_logoImageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.and.right.and.bottom.mas_equalTo(0);
        }];
        FCSETLRViewBorderRadius(_logoImageLabel, 24);
        _logoImageLabel.font = font12;
        _logoImageLabel.textColor = FCWhiteColor;
        _logoImageLabel.textAlignment = NSTextAlignmentCenter;
        
        _companyNameLabel = [UILabel new];
        [_view addSubview:_companyNameLabel];
        [_companyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.avatarImageView.mas_top).mas_equalTo(0);
            make.left.equalTo(weakSelf.avatarImageView.mas_right).mas_equalTo(9);
            make.right.mas_equalTo(-16);
            make.height.mas_equalTo(22);
        }];
        _companyNameLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16];
        _companyNameLabel.textColor = FCTxtColor;
        _companyNameLabel.numberOfLines = 1;
        
        _mainBusinessLabel = [UILabel new];
        [_view addSubview:_mainBusinessLabel];
        [_mainBusinessLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.companyNameLabel.mas_bottom).mas_equalTo(2);
            make.left.equalTo(weakSelf.companyNameLabel.mas_left).mas_equalTo(0);
            make.right.mas_equalTo(-16);
        }];
        _mainBusinessLabel.font = font14;
        _mainBusinessLabel.textColor = FCGrayTxtDetailColor;
        _mainBusinessLabel.numberOfLines = 0;
        
        UIView *lineView1 = [UIView new];
        [_view addSubview:lineView1];
        [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.avatarImageView.mas_bottom).mas_equalTo(16);
            make.left.mas_equalTo(16);
            make.right.mas_equalTo(-16);
            make.height.mas_equalTo(1);
        }];
        lineView1.backgroundColor = FCLineColor;
        
        UIView *addressView = [UIView new];
        [_view addSubview:addressView];
        [addressView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView1.mas_bottom).mas_offset(0);
            if (IphonePlus) {
                make.height.mas_offset(54);
            } else{
                make.height.mas_offset(48);
            }
            make.left.and.right.mas_equalTo(0);
        }];
        
        UILabel *address = [UILabel new];
        [addressView addSubview:address];
        [address mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(0);
            make.left.mas_equalTo(16);
            make.width.mas_equalTo(48);
        }];
        address.font = font14;
        address.textColor = FCGrayTxtDetailColor;
        address.numberOfLines = 1;
        address.text = customerRelationLocaChanged(@"global_general_add_black_address", @"地址");
        
        _addressLabel = [UILabel new];
        [addressView addSubview:_addressLabel];
        [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(address).mas_equalTo(0);
            make.right.mas_equalTo(-16);
            make.left.equalTo(address.mas_right).mas_equalTo(10);
        }];
        _addressLabel.font = font14;
        _addressLabel.textColor = FCTxtColor;
        _addressLabel.numberOfLines = 1;
        _addressLabel.textAlignment = NSTextAlignmentRight;
        
        UIView *lineView2 = [UIView new];
        [_view addSubview:lineView2];
        [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(addressView.mas_bottom).mas_equalTo(0);
            make.left.mas_equalTo(16);
            make.right.mas_equalTo(-16);
            make.height.mas_equalTo(1);
        }];
        lineView2.backgroundColor = FCLineColor;
        
        UIView *phoneView = [UIView new];
        [_view addSubview:phoneView];
        [phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView2.mas_bottom).mas_offset(0);
            if (IphonePlus) {
                make.height.mas_offset(54);
            } else{
                make.height.mas_offset(48);
            }
            make.bottom.mas_equalTo(0);
            make.left.and.right.mas_equalTo(0);
        }];
        
        UILabel *phone = [UILabel new];
        [phoneView addSubview:phone];
        [phone mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(0);
            make.left.mas_equalTo(16);
        }];
        phone.font = font14;
        phone.textColor = FCGrayTxtDetailColor;
        phone.numberOfLines = 1;
        phone.text = customerRelationLocaChanged(@"负责人手机号", @"负责人手机号");
        
        _phoneView = [UIView new];
        [phoneView addSubview:_phoneView];
        [_phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(phone).mas_equalTo(0);
            make.right.mas_equalTo(-16);
            make.left.equalTo(phone.mas_right).mas_equalTo(10);
            make.height.mas_equalTo(20);
        }];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    BA_ViewBorderRadius(_view, 4, 0.5, FCEnableColor);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
